home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / utilities / easyproc2.lha / EasyProcess / launch / ParentSig.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-05  |  1.2 KB  |  74 lines

  1. #include "Launch.h"
  2. #include "LaunchPriv.h"
  3.  
  4.  
  5. /*
  6.  *    NAME
  7.  *        AllocParentSignal -- Allocate a signal for child notification.
  8.  *
  9.  *    SYNOPSIS
  10.  *        bit = AllocParentSignal ()
  11.  *
  12.  *        LONG AllocParentSignal (void);
  13.  *
  14.  *    DESCRIPTION
  15.  *        Check if we already launched a process and try to use the same
  16.  *        bit for all processes.  If we can't find a process pair, we
  17.  *        allocate a new bit.
  18.  *
  19.  *    INPUT
  20.  *        None.
  21.  *
  22.  *    OUTPUT
  23.  *        bit - the allocated bit number.
  24.  *
  25.  *    HISTORY
  26.  *        1992/09/07    Pierre Baillargeon        Creation
  27.  */
  28.  
  29. LONG AllocParentSignal (void)
  30. {
  31.     struct ProcPair *Parent;
  32.  
  33.     if (NULL != (Parent = IsParent ((struct Process *)FindTask (NULL))))
  34.     {
  35.         return Parent->pp_ParentBit;
  36.     }
  37.     else
  38.     {
  39.         return (LONG)AllocSignal (-1L);
  40.     }
  41. }
  42.  
  43.  
  44. /*
  45.  *    NAME
  46.  *        FreeParentSignal -- free the signal if it's not used by other.
  47.  *
  48.  *    SYNOPSIS
  49.  *        FreeParentSignal (bit)
  50.  *
  51.  *        void FreeParentSignal (LONG);
  52.  *
  53.  *    DESCRIPTION
  54.  *        Check if the signal bit number is valid and if it is not used
  55.  *        by another process pair.  If not, free it.
  56.  *
  57.  *    INPUT
  58.  *        bit - the bit number.
  59.  *
  60.  *    OUTPUT
  61.  *        None.
  62.  *
  63.  *    HISTORY
  64.  *        1992/09/07    Pierre Baillargeon        Creation
  65.  */
  66.  
  67. void FreeParentSignal (LONG Bit)
  68. {
  69.     if (-1L != Bit && NULL == IsParent ((struct Process *)FindTask (NULL)))
  70.     {
  71.         FreeSignal (Bit);
  72.     }
  73. }
  74.